< previous page page_636 next page >

Page 636
Table 16.2. The field list for the Skills and SkillMaster tables.
EmpSkillsSkillMaster
EmpIDSkillCode
SkillCodeSkillName
SkillDeptID
SkillLevel

You can see that you have renamed the Skills table to EmpSkills to better reflect its contents. You have also moved the SkillName field out of the EmpSkills table and created SkillMaster, a small table that contains a list of all the valid skills and their descriptive names. Now you have the added bonus of being able to add a FOREIGN KEY constraint to the EmpSkills table. This improves database integrity without adding any additional programming code!
Listing 16.3 shows the two SQL DDL statements that create the EmpSkills and the SkillMaster data tables. Note the use of FOREIGN KEY constraints in the EmpSkills table.
Type.gifListing 16.3. Creating the SkillMaster and EmpSkills tables.
CREATE TABLE SkillMaster
   (SkillCode TEXT(5),
    SkillName TEXT(20),
    CONSTRAINT PKSkillMaster PRIMARY KEY (SkillCode))
CREATE TABLE EmpSkills
   (EmpID TEXT(5),
    SkillCode TEXT(5),
    SkillDeptID TEXT(5),
    SkillLevel INTEGER,
    CONSTRAINT PKSkills PRIMARY KEY (SkillCode,EmpID),
    CONSTRAINT FKEmpID2 FOREIGN KEY (EmpID)
       REFERENCES Employees(EmpID),
    CONSTRAINT FKSkillCode FOREIGN KEY (SkillCode)
       REFERENCES SkillMaster(SkillCode));
Use Visdata to add these two new tables to the NORMDAT2.MDB database. The database TYSDBVB5\SOURCE\DATA\NORMDAT3.MDB contains a complete database with the data tables Employees, EmpSkills, and SkillMaster fully populated with data. This is demonstrated in Figure 16.4.
You now have a database that conforms to the first two rules of data normalization. You have eliminated repeating data and redundant data. You have one more type of data to eliminate from your tables. You handle that in the following section.

 
< previous page page_636 next page >

If you like this book, buy it!